<template>
  <div class="index">
    后台首页
    <!-- {{ $store.state.user.username }} -->
    <el-button @click="logout">退出登录</el-button>
  </div>
</template>

<script setup>
  import { showModal, toast } from '@/utils'
  import { logoutApi } from '@/api/manager'
  import { useRouter } from 'vue-router'
  import { useStore } from 'vuex'

  const router = useRouter()
  const store = useStore()

  function logout() {
    showModal('提示', 'warning', '是否退出登录').then((res) => {
      store.dispatch('logoutAction').then((res) => {
        toast('退出登录成功')
        router.push({ path: '/login' })
      })
    })
  }
</script>

<style scoped></style>
